<script setup>

</script>

<template>
  <div style="display: flex;line-height: 60px">
    <div style="flex: 1;text-align: center;font-size: 25px">
      <span style="color: #45494d">按 摩 店 会 员 管 理 系 统</span>
    </div>
  <el-dropdown>
    <i class="el-icon-setting" style="margin-right: 15px"></i>
    <el-dropdown-menu slot="dropdown">
      <el-dropdown-item @click.native="toUser">个人中心</el-dropdown-item>
      <el-dropdown-item @click.native="logout">退出登录</el-dropdown-item>
    </el-dropdown-menu>
  </el-dropdown>
  <span>{{ user.name }}</span>
  </div>
</template>
<script>
export default {
  name:"MyHeader",
  data(){
    return {
      user:JSON.parse(sessionStorage.getItem('CurUser'))
  }
  },
  methods: {
    toUser() {
      console.log("to_user")
      this.$router.push("/MyHome")

    },
    logout() {
      console.log("logout")
      this.$router.push("/")
      sessionStorage.clear()
    }
  },
  created() {
    if (this.$route.path !== '/MyHome') {
      this.$router.push('/MyHome');
    }
  }
}
</script>

<style scoped>

</style>